<template>
  <el-container v-loading="loading">
    <el-header height="75px" id="headers">
      <div class="header1">
        <header1></header1>
      </div>
    </el-header>
    <el-main id="el-main">
      <router-view v-if="loadings"></router-view>
    </el-main>
  </el-container>
</template>

<script>
import header1 from "@/components/header1.vue";
import { mapActions } from "vuex";

export default {
  name: "myclass",
  data() {
    return {
      loading: false,
      loadings: false
    };
  },
  async beforeMount() {
    let x;
    try {
      x = await this.session();
      if (!x) {
        this.$message.error("账号还没有审核");
        this.$router.push("/login");
      }
    } catch (e) {
      this.$message.error("登陆已失效");
      this.$router.push("/login");
    }
  },
  async mounted() {
    this.loading = true;
    await this.actionCatebag();
    await this.actionCourse();
    await this.actionCatebagtype();
    await this.actionuserCourse();
    await this.actionuserUsercourse();
    this.loading = false;
    this.loadings = true;
  },
  methods: {
    ...mapActions([
      "session",
      "actionCatebag",
      "actionCourse",
      "actionCatebagtype",
      "actionuserCourse",
      "actionuserUsercourse"
    ])
  },
  components: {
    header1
  }
};
</script>
<style scoped>
#el-main {
  padding: 0;
  min-width: 1200px;
}

#headers {
  min-width: 1200px;
  background-color: rgb(47, 129, 241);
}
.header1 {
  width: 1200px;
  margin: 0 auto;
}
</style>
